package com.ghsc.ghxc.jsb.ui.integral.view

import android.content.Context
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.ghsc.ghxc.jsb.R
import com.ghsc.ghxc.jsb.ui.integral.bean.KuaiDiBean
import com.lxj.xpopup.core.BottomPopupView

/**
 * 项目：GuoHuaJsb
 * 包名：com.ghsc.ghxc.jsb.ui.integral.view
 * 类名：KuaiDiListPopupView
 * 创建时间：2024/5/24 11:51
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class KuaiDiListPopupView (context: Context, mList :MutableList<KuaiDiBean>, tvBtnSub:(item: String)->Unit,) : BottomPopupView(context) {
    private val mContext = context
    override fun getImplLayoutId() = R.layout.live_audience_list
    private var tvBtnSub: (item: String) -> Unit = tvBtnSub
    var mList = mList
    val mAdapter = ListAdapter()

    override fun onCreate() {
        super.onCreate()
        findViewById<TextView>(R.id.tvTitl).text="快递名称"
        var  rvList= findViewById<RecyclerView>(R.id.rvList)
        rvList.layoutManager = LinearLayoutManager(mContext)
        rvList.adapter = mAdapter
        mAdapter.replaceData(mList)
        mAdapter.setOnItemClickListener { adapter, view, position ->
            tvBtnSub.invoke( mAdapter.getItem(position).kdname.toString())
            dismiss()
        }
    }
    override fun onDestroy() {
        super.onDestroy()
    }
    override fun getMaxWidth() = 0
    class ListAdapter  : BaseQuickAdapter<KuaiDiBean, BaseViewHolder>(
        R.layout.gropu_type_item) {
        override fun convert(helper: BaseViewHolder, item: KuaiDiBean) {
            helper.setText(R.id.tvName,item.kdname.toString())
                .setGone(R.id.isCheck, true)
                .setGone(R.id.imgIcon, true)


        }
    }
}